home *** CD-ROM | disk | FTP | other *** search
- package javax.swing;
-
- import java.awt.Component;
- import java.awt.Image;
- import java.io.IOException;
- import java.io.ObjectOutputStream;
- import javax.accessibility.Accessible;
- import javax.accessibility.AccessibleContext;
- import javax.swing.plaf.LabelUI;
-
- public class JLabel extends JComponent implements SwingConstants, Accessible {
- private static final String uiClassID = "LabelUI";
- private int mnemonic;
- private String text;
- private Icon defaultIcon;
- private Icon disabledIcon;
- private boolean disabledIconSet;
- private int verticalAlignment;
- private int horizontalAlignment;
- private int verticalTextPosition;
- private int horizontalTextPosition;
- private int iconTextGap;
- protected Component labelFor;
- static final String LABELED_BY_PROPERTY = "labeledBy";
-
- public JLabel() {
- this("", (Icon)null, 10);
- }
-
- public JLabel(String var1) {
- this(var1, (Icon)null, 10);
- }
-
- public JLabel(String var1, int var2) {
- this(var1, (Icon)null, var2);
- }
-
- public JLabel(String var1, Icon var2, int var3) {
- this.mnemonic = 0;
- this.text = "";
- this.defaultIcon = null;
- this.disabledIcon = null;
- this.disabledIconSet = false;
- this.verticalAlignment = 0;
- this.horizontalAlignment = 10;
- this.verticalTextPosition = 0;
- this.horizontalTextPosition = 11;
- this.iconTextGap = 4;
- this.labelFor = null;
- this.setText(var1);
- this.setIcon(var2);
- this.setHorizontalAlignment(var3);
- this.updateUI();
- ((JComponent)this).setAlignmentX(0.0F);
- }
-
- public JLabel(Icon var1) {
- this((String)null, var1, 0);
- }
-
- public JLabel(Icon var1, int var2) {
- this((String)null, var1, var2);
- }
-
- protected int checkHorizontalKey(int var1, String var2) {
- if (var1 != 2 && var1 != 0 && var1 != 4 && var1 != 10 && var1 != 11) {
- throw new IllegalArgumentException(var2);
- } else {
- return var1;
- }
- }
-
- protected int checkVerticalKey(int var1, String var2) {
- if (var1 != 1 && var1 != 0 && var1 != 3) {
- throw new IllegalArgumentException(var2);
- } else {
- return var1;
- }
- }
-
- public AccessibleContext getAccessibleContext() {
- if (super.accessibleContext == null) {
- super.accessibleContext = new AccessibleJLabel(this);
- }
-
- return super.accessibleContext;
- }
-
- public Icon getDisabledIcon() {
- if (!this.disabledIconSet && this.disabledIcon == null && this.defaultIcon != null && this.defaultIcon instanceof ImageIcon) {
- Image var1 = GrayFilter.createDisabledImage(((ImageIcon)this.defaultIcon).getImage());
- this.disabledIcon = new ImageIcon(var1);
- ((JComponent)this).firePropertyChange("disabledIcon", (Object)null, this.disabledIcon);
- }
-
- return this.disabledIcon;
- }
-
- public int getDisplayedMnemonic() {
- return this.mnemonic;
- }
-
- public int getHorizontalAlignment() {
- return this.horizontalAlignment;
- }
-
- public int getHorizontalTextPosition() {
- return this.horizontalTextPosition;
- }
-
- public Icon getIcon() {
- return this.defaultIcon;
- }
-
- public int getIconTextGap() {
- return this.iconTextGap;
- }
-
- public Component getLabelFor() {
- return this.labelFor;
- }
-
- public String getText() {
- return this.text;
- }
-
- public LabelUI getUI() {
- return (LabelUI)super.ui;
- }
-
- public String getUIClassID() {
- return "LabelUI";
- }
-
- public int getVerticalAlignment() {
- return this.verticalAlignment;
- }
-
- public int getVerticalTextPosition() {
- return this.verticalTextPosition;
- }
-
- protected String paramString() {
- String var1 = this.text != null ? this.text : "";
- String var2 = this.defaultIcon != null ? this.defaultIcon.toString() : "";
- String var3 = this.disabledIcon != null ? this.disabledIcon.toString() : "";
- String var4 = this.labelFor != null ? this.labelFor.toString() : "";
- String var5;
- if (this.verticalAlignment == 1) {
- var5 = "TOP";
- } else if (this.verticalAlignment == 0) {
- var5 = "CENTER";
- } else if (this.verticalAlignment == 3) {
- var5 = "BOTTOM";
- } else {
- var5 = "";
- }
-
- String var6;
- if (this.horizontalAlignment == 2) {
- var6 = "LEFT";
- } else if (this.horizontalAlignment == 0) {
- var6 = "CENTER";
- } else if (this.horizontalAlignment == 4) {
- var6 = "RIGHT";
- } else {
- var6 = "";
- }
-
- String var7;
- if (this.verticalTextPosition == 1) {
- var7 = "TOP";
- } else if (this.verticalTextPosition == 0) {
- var7 = "CENTER";
- } else if (this.verticalTextPosition == 3) {
- var7 = "BOTTOM";
- } else {
- var7 = "";
- }
-
- String var8;
- if (this.horizontalTextPosition == 2) {
- var8 = "LEFT";
- } else if (this.horizontalTextPosition == 0) {
- var8 = "CENTER";
- } else if (this.horizontalTextPosition == 4) {
- var8 = "RIGHT";
- } else {
- var8 = "";
- }
-
- return super.paramString() + ",defaultIcon=" + var2 + ",disabledIcon=" + var3 + ",horizontalAlignment=" + var6 + ",horizontalTextPosition=" + var8 + ",iconTextGap=" + this.iconTextGap + ",labelFor=" + var4 + ",text=" + var1 + ",verticalAlignment=" + var5 + ",verticalTextPosition=" + var7;
- }
-
- public void setDisabledIcon(Icon var1) {
- Icon var2 = this.disabledIcon;
- this.disabledIcon = var1;
- this.disabledIconSet = true;
- ((JComponent)this).firePropertyChange("disabledIcon", var2, var1);
- if (var1 != var2) {
- if (var1 == null || var2 == null || var1.getIconWidth() != var2.getIconWidth() || var1.getIconHeight() != var2.getIconHeight()) {
- ((JComponent)this).revalidate();
- }
-
- if (!((Component)this).isEnabled()) {
- ((Component)this).repaint();
- }
- }
-
- }
-
- public void setDisplayedMnemonic(char var1) {
- int var2 = var1;
- if (var1 >= 'a' && var1 <= 'z') {
- var2 = var1 - 32;
- }
-
- this.setDisplayedMnemonic(var2);
- }
-
- public void setDisplayedMnemonic(int var1) {
- int var2 = this.mnemonic;
- this.mnemonic = var1;
- ((JComponent)this).firePropertyChange("displayedMnemonic", var2, this.mnemonic);
- if (var1 != var2) {
- ((JComponent)this).revalidate();
- ((Component)this).repaint();
- }
-
- }
-
- public void setHorizontalAlignment(int var1) {
- if (var1 != this.horizontalAlignment) {
- int var2 = this.horizontalAlignment;
- this.horizontalAlignment = this.checkHorizontalKey(var1, "horizontalAlignment");
- ((JComponent)this).firePropertyChange("horizontalAlignment", var2, this.horizontalAlignment);
- ((Component)this).repaint();
- }
- }
-
- public void setHorizontalTextPosition(int var1) {
- int var2 = this.horizontalTextPosition;
- this.horizontalTextPosition = this.checkHorizontalKey(var1, "horizontalTextPosition");
- ((JComponent)this).firePropertyChange("horizontalTextPosition", var2, this.horizontalTextPosition);
- ((Component)this).repaint();
- }
-
- public void setIcon(Icon var1) {
- Icon var2 = this.defaultIcon;
- this.defaultIcon = var1;
- if (this.defaultIcon != var2 && !this.disabledIconSet) {
- this.disabledIcon = null;
- }
-
- ((JComponent)this).firePropertyChange("icon", var2, this.defaultIcon);
- if (super.accessibleContext != null && var2 != this.defaultIcon) {
- super.accessibleContext.firePropertyChange("AccessibleVisibleData", var2, this.defaultIcon);
- }
-
- if (this.defaultIcon != var2) {
- if (this.defaultIcon == null || var2 == null || this.defaultIcon.getIconWidth() != var2.getIconWidth() || this.defaultIcon.getIconHeight() != var2.getIconHeight()) {
- ((JComponent)this).revalidate();
- }
-
- ((Component)this).repaint();
- }
-
- }
-
- public void setIconTextGap(int var1) {
- int var2 = this.iconTextGap;
- this.iconTextGap = var1;
- ((JComponent)this).firePropertyChange("iconTextGap", var2, var1);
- if (var1 != var2) {
- ((JComponent)this).revalidate();
- ((Component)this).repaint();
- }
-
- }
-
- public void setLabelFor(Component var1) {
- Component var2 = this.labelFor;
- this.labelFor = var1;
- ((JComponent)this).firePropertyChange("labelFor", var2, var1);
- if (var2 instanceof JComponent) {
- ((JComponent)var2).putClientProperty("labeledBy", (Object)null);
- }
-
- if (var1 instanceof JComponent) {
- ((JComponent)var1).putClientProperty("labeledBy", this);
- }
-
- }
-
- public void setText(String var1) {
- String var2 = null;
- if (super.accessibleContext != null) {
- var2 = super.accessibleContext.getAccessibleName();
- }
-
- String var3 = this.text;
- this.text = var1;
- ((JComponent)this).firePropertyChange("text", var3, var1);
- if (super.accessibleContext != null && super.accessibleContext.getAccessibleName() != var2) {
- super.accessibleContext.firePropertyChange("AccessibleVisibleData", var2, super.accessibleContext.getAccessibleName());
- }
-
- if (var1 == null || var3 == null || !var1.equals(var3)) {
- ((JComponent)this).revalidate();
- ((Component)this).repaint();
- }
-
- }
-
- public void setUI(LabelUI var1) {
- super.setUI(var1);
- }
-
- public void setVerticalAlignment(int var1) {
- if (var1 != this.verticalAlignment) {
- int var2 = this.verticalAlignment;
- this.verticalAlignment = this.checkVerticalKey(var1, "verticalAlignment");
- ((JComponent)this).firePropertyChange("verticalAlignment", var2, this.verticalAlignment);
- ((Component)this).repaint();
- }
- }
-
- public void setVerticalTextPosition(int var1) {
- if (var1 != this.verticalTextPosition) {
- int var2 = this.verticalTextPosition;
- this.verticalTextPosition = this.checkVerticalKey(var1, "verticalTextPosition");
- ((JComponent)this).firePropertyChange("verticalTextPosition", var2, this.verticalTextPosition);
- ((Component)this).repaint();
- }
- }
-
- public void updateUI() {
- this.setUI((LabelUI)UIManager.getUI(this));
- }
-
- private void writeObject(ObjectOutputStream var1) throws IOException {
- var1.defaultWriteObject();
- if (super.ui != null && this.getUIClassID().equals("LabelUI")) {
- super.ui.installUI(this);
- }
-
- }
- }
-